<template>
	<view class="outpatient-serve-detail">
		<view v-for="(item,index) in listData" :key="index" class="outpatient-serve-detail-main">
			<view class="card-row" v-for="cItem in cardLabel" :key='cItem.fKey' :style="{color:item.unit=='元'?orageColor:''}"> <label>{{cItem.label}}</label>{{item[cItem.key]||''}} </view>
			<view class="div-cut"></view>
		</view>
		<Load :load="load"></Load>
	</view>
</template>

<script>
	import Load from '@/components/Load/index.vue'
	import { getPayDetail, getPayDetails } from '@/api/home.js'
	import { orageColor } from '@/static/js/theme.js'
	export default {
		components: { Load },
		data() {
			return {
				listData:[{},{}],
				cardLabel:[
					{
						label:'项目名称：',
						key:'ypmc',
						fKey:'label11',
						unit:''
					},
					{
						label:'项目数量：',
						key:'ypsl',
						fKey:'label21',
						unit:''
					},
					{
						label:'项目单价：',
						key:'ypdj',
						fKey:'label31',
						unit:'元'
					},
					{
						label:'项目规格：',
						key:'gg',
						fKey:'label41',
						unit:''
					},
					{
						label:'项目金额：',
						key:'zje',
						fKey:'label51',
						unit:'元'
					}
				],
				load:false,
				jssjh:null,
				cfxh:null
			}
		},
		onLoad(op) {
			if(op.jssjh){
				// 从我的缴费页面过来
				this.jssjh = op.jssjh 
			}
			if(op.cfxh){
				// 从处方缴费过来
				this.cfxh = op.cfxh
			}
			this.initData()
		},
		methods: {
			initData(){
				this.load = true
				let params = {}
				if(this.jssjh){
					params.jssjh = this.jssjh
					getPayDetail(params).then(data => {
						this.load = false
						this.listData = data||[]
					}).catch(e => {
						this.listData = []
						this.load = false
					})
				}else if(this.cfxh){
					params.cfxh = this.cfxh
					getPayDetails(params).then(data => {
						this.load = false
						this.listData = data||[]
					}).catch(e => {
						this.listData = []
						this.load = false
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.outpatient-serve-detail{
		height: calc(100vh);
		overflow: scroll;
		background-color: $uni-bg-color;
		&-main{
			padding-top: 30rpx;
			>.card-row{
				padding: 0 30rpx;
			}
			>.div-cut{
				margin: 20rpx 0;
			}
		}
	}
</style>